package com.fs.myview;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.studentmanagersystem.R;
import com.fs.po.UserData;

/**
 * 自定义对话框，当点击用户列表时，弹出显示所有用户信息
 * @author chenwenfei
 *
 */
public class UserListDialog extends RelativeLayout{

	private View view;
	private TextView titleTextView,infoTextId,infoTextName,infoTextPsw,infoTextTel,infoTextSex,infoTextAge,infoTextClass;
	private Context context;
	private UserData userlistData;
	
	public UserListDialog(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context=context;
	}

	public UserListDialog(Context context,UserData userlistData) {
		super(context);
		this.context=context;
		this.userlistData=userlistData;
	}
	
	public View setView() {
		this.view = ((Activity) context).getLayoutInflater().inflate(R.layout.userlist_dialog, null);
		
		
		
		this.titleTextView=(TextView) view.findViewById(R.id.userlist_diaolog_title);
		this.infoTextId=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_id);
		this.infoTextName=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_name);
		this.infoTextPsw=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_password);
		this.infoTextTel=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_tel);
		this.infoTextSex=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_sex);
		this.infoTextAge=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_age);
		this.infoTextClass=(TextView) view.findViewById(R.id.userlist_diaolog_userinfo_class);
		
		this.setData();
		return view;
	}
	
	public void setData() {
		
		this.titleTextView.setText(userlistData.getName());
		this.infoTextId.setText("id："+userlistData.getUser_id());
		this.infoTextName.setText("姓名："+userlistData.getName());
		this.infoTextPsw.setText("密码："+userlistData.getPassword());
		this.infoTextTel.setText("电话："+userlistData.getTel());
		this.infoTextSex.setText("性别："+userlistData.getSex());
		this.infoTextAge.setText("年龄："+userlistData.getAge());
		this.infoTextClass.setText("课程："+userlistData.getClass_id());
		
	}
}
